package com.ruoyi.lock.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.lock.domain.vo.PasswordGenerationVo;
import com.ruoyi.lock.service.OfflinePasswordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/offlinePassword")
@Slf4j
public class OfflinePasswordCollection {

    @Autowired
    private OfflinePasswordService offlinePasswordServicel;

    /**
     * 生成开锁密码 1: 一次性密码 2：周期密码 3：永久密码
     * @return
     */
    @GetMapping("/passwordGeneration")
    public AjaxResult passwordGeneration(PasswordGenerationVo passwordGenerationVo) {
        if (passwordGenerationVo.getHomeId() == null || passwordGenerationVo.getType() == null) {
            return AjaxResult.error("参数错误！");
        }
        return offlinePasswordServicel.passwordGeneration(passwordGenerationVo);
    }
}
